package com.utonw.carloan.fragment.applyloan;

import android.content.Intent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.sensetime.library.finance.ocr.card.IdCardInfo;
import com.utonw.carloan.R;
import com.utonw.carloan.fragment.BaseFragment;
import com.utonw.carloan.function.GlobalLoanFunction;
import com.utonw.carloan.utils.ChooseBarUtils;

import java.util.ArrayList;

/**
 * Created by SEELE on 2017/3/22.
 */

/**
 * 申请贷款流程3：房产信息
 */
public  class LoanStepThreeFragment extends BaseFragment {
    //是否有房产布局
    private LinearLayout mHasHouse;
    //初始化全局方法
    private GlobalLoanFunction mGlobalLoanFunction;

    @Override
    public int setLayout() {
        return R.layout.fragment_applyloan_step_three;
    }

    @Override
    public void initView(View view) {

        mHasHouse = (LinearLayout) mActivity.findViewById(R.id.ll_has_house);
        //默认不显示房产信息
        mHasHouse.setVisibility(View.GONE);
    }

    @Override
    public void initData() {
        //初始化PickerView选择器
        mGlobalLoanFunction = new GlobalLoanFunction();
        //初始化PickerView选择器
        final GlobalLoanFunction globalLoanFunction = new GlobalLoanFunction();
        //设置ChooseBar标题
        ChooseBarUtils titleUtils = new ChooseBarUtils(getHoldingActivity()) {
            @Override
            protected void setChooseBarClickListener(int view) {

            }

            @Override
            protected void setChooseBarClickListener(int view, TextView toShow) {

                switch (view) {
                    case R.id.goumaishijian:

                        globalLoanFunction.setTempData(null, toShow).timePickerView(getContext());

                        break;

                    case R.id.goumaifangshi:

                        final ArrayList<String> data1 = new ArrayList<>();
                        data1.add("一次性");
                        data1.add("按揭");
                        globalLoanFunction.setTempData(data1, toShow).oriPickerView(getContext());

                        break;

                    case R.id.fangchanguishuren:

                        final ArrayList<String> data2 = new ArrayList<>();
                        data2.add("本人名下");
                        data2.add("配偶或父母名下");
                        data2.add("自建房");
                        data2.add("其他");
                        globalLoanFunction.setTempData(data2, toShow).oriPickerView(getContext());

                        break;

                }
            }

            @Override
            protected void getCheckedViewListener(int includeId, int sTitle, View toCheck) {
                setCheckViews(sTitle, toCheck);
            }

            @Override
            public void onToggleButtonListener(int buttonView, boolean isChecked) {
                switch (buttonView) {
                    case R.id.shifouyoufangchan:
                        if (isChecked) {
                            mHasHouse.setVisibility(View.VISIBLE);
                        } else {
                            mHasHouse.setVisibility(View.GONE);
                        }
                        break;

                }


            }

            @Override
            public void getEditTextWithTipsListener(int includeId, EditText tempEt1) {

            }

            @Override
            public void onRadioButtonListener(RadioButton rMale, RadioButton rFemale) {

            }

            @Override
            public void onImageChooseBarListener(int view, ImageView mIndicator, TextView mInstruction, int sTitle) {
                switch (view) {
                    case R.id.fangchanzhengtupian:
                        uploadImageData(mGlobalLoanFunction,mIndicator, mInstruction, sTitle);
                        break;

                }
            }

            @Override
            public void getChangeWordsEditTextListener(int includeId, EditText tempEt1, int sTitle) {


            }

            @Override
            public void setVerificationListener() {

            }
        };

        titleUtils.initChooseBar("0","0", "hasHouse", R.id.shifouyoufangchan, R.string.apply_page_three_is_have_house, ChooseBarUtils.ResultState.TOGGLE_BUTTON, null);
        titleUtils.initChooseBar("0","0", "houseNumber", R.id.fangchanshuliang, R.string.apply_page_three_house_amount, ChooseBarUtils.ResultState.EDIT_TEXT_WITH_TIPS, "套");
        titleUtils.initChooseBar("0","0", "houseBuyDate", R.id.goumaishijian, R.string.apply_page_three_buy_time);
        titleUtils.initChooseBar("0","0", "houseBuyWay", R.id.goumaifangshi, R.string.apply_page_three_buy_type);
        titleUtils.initChooseBar("0","0", "houseMonthlyMortgagePayment", R.id.yuegong, R.string.apply_page_three_pay_by_month, ChooseBarUtils.ResultState.CHANGE_WORDS, "请输入月供/元");
        titleUtils.initChooseBar("0","0", "houseBuyPrice", R.id.goumaijiage, R.string.apply_page_three_buy_price, ChooseBarUtils.ResultState.CHANGE_WORDS, "请输入购买价格");
        titleUtils.initChooseBar("0","0", "houseOwnership", R.id.fangchanguishuren, R.string.apply_page_three_belong_who);
        titleUtils.initChooseBar("0","0", "houseAddr", R.id.fangchandizhi, R.string.apply_page_three_house_local, ChooseBarUtils.ResultState.EDIT_TEXT_WITH_TIPS, "");
        titleUtils.initChooseBar("0","0", "fangchanzheng", R.id.fangchanzhengtupian, R.string.apply_page_three_house_data, ChooseBarUtils.ResultState.ORI_WITH_IMAGE, null);
    }

    @Override
    protected void getIdcardFrontInfo(IdCardInfo idCardInfo) {

    }

    @Override
    protected void getIdcardBackInfo(IdCardInfo idCardInfo) {

    }

    @Override
    protected void getBankcardInfo(Intent cardData) {

    }

    @Override
    protected void getCreditcardInfo(Intent cardData) {

    }


}
